<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .father {
            width: 300px;
            height: 300px;
            border: 1px solid #000;
        }

        .son {
            width: 100px;
            height: 100px;
            background-color: #f00;
        }
    </style>
</head>
<body>
    <div id="app">
        <!-- .self，代表这个事件只有能由它自己触发，不会经过冒泡触发 -->
        <div @click.self="fatherFn" class="father">
            <!-- .stop阻止冒泡 -->
            <div @click.stop="fn2" class="son"></div>
            <!-- .prevent阻止默认行为 -->
            <!-- 我既想阻止默认行为，又想阻止冒泡 -->
            <a @click.stop.prevent="fn1" href="http://www.baidu.com">点我会跳转</a>

            <!-- 只绑定一次事件 -->
            <button @click.once="fn3">点我啊</button>
            <button @click="fn3">点我啊</button>
            <button @click="fn3">点我啊</button>
        </div>
    </div>

    <script src="./vue.js"></script>
    <script>
        new Vue({
            el: '#app',
            methods: {
                fatherFn () {
                    console.log('父盒子被点了')
                },
                fn1 () {
                    console.log('a标签被点了')
                },
                fn2 () {
                    console.log('son被点了')
                },
                fn3 () {
                    console.log('按钮被点了')
                }
            }
        })
    </script>
</body>
</html>